package drds.binlog.parse;

import drds.binlog.common.AbstractLifeCycle;
import drds.binlog.common.Authors;
import drds.common.Author;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;


@Author(name = Authors.LI_YANG)
public class GroupEventParser extends AbstractLifeCycle implements IEventParser
{

    @Setter
    @Getter
    private List<IEventParser> eventParserList = new ArrayList<IEventParser>();

    public void start()
    {
        super.start();
        // 统一启动
        for (IEventParser eventParser : eventParserList)
        {
            if (!eventParser.isRunning())
            {
                eventParser.start();
            }
        }
    }

    public void stop()
    {
        super.stop();
        // 统一关闭
        for (IEventParser eventParser : eventParserList)
        {
            if (eventParser.isRunning())
            {
                eventParser.stop();
            }
        }
    }

}
